package codeComposition;
import java.util.*;
public class CallFuctionElement extends ExpressionElement {
	String ref;
	String func;
	ArrayList<Element> argus;
	String to;
	
	public CallFuctionElement(String ref, String func, 
			ArrayList<Element> argus){
		this.ref = ref;
		this.func = func;
		this.argus = argus;
	}
	
	public CallFuctionElement(String ref, String func, 
			ArrayList<Element> argus, String to){
		this(ref, func, argus);
		this.to = to;
	}
	
	public CallFuctionElement(String ref, String func){
		this.ref = ref;
		this.func = func;
		this.argus = null;
	}
	
	public CallFuctionElement(String ref, String func, 
			String to){
		this(ref, func);
		this.to = to;
	}
	public CallFuctionElement(String ref, String func, 
			ArrayList<Element> argus, int tabNum){
		super(tabNum);
		this.ref = ref;
		this.func = func;
		this.argus = argus;
	}
	
	public CallFuctionElement(String ref, String func, 
			ArrayList<Element> argus, String to, int tabNum){
		this(ref, func, argus, tabNum);
		this.to = to;
	}
	
	public CallFuctionElement(String ref, String func, 
			int tabNum){
		super(tabNum);
		this.ref = ref;
		this.func = func;
		this.argus = null;
	}
	
	public CallFuctionElement(String ref, String func, 
			String to, int tabNum){
		this(ref, func, tabNum);
		this.to = to;
	}
	
	public String toString(){
		String str = this.tabStr;
		if(this.to != null){
			str = str + this.to.toString() + " = ";
		}
		str += ref.toString() + "."+ func + "(";
		if(this.argus != null){
			int i = 1;
			for(Element argu:argus){
				str = str + argu.toString();
				if(i<argus.size()){
					str += ", ";
				}
				i++;
			}
		}
		str += ")\n";
		return str;
	}
	public static void main(String[] argvs){
		String to = new String("to");
		String ref = new String("ref");
		ArrayList<Element> argus = new ArrayList<Element>();
		argus.add(new ReferenceElement("argu1"));
		argus.add(new ReferenceElement("argu2"));
		CallFuctionElement lae = new CallFuctionElement(ref, "func", to);
		CallFuctionElement lae2 = new CallFuctionElement(ref, "func", to, 1);
		CallFuctionElement lae3 = new CallFuctionElement(ref, "func", argus, to);
		CallFuctionElement lae4 = new CallFuctionElement(ref, "func", argus, to, 1);
		
		CallFuctionElement lae5 = new CallFuctionElement(ref, "func");
		CallFuctionElement lae6 = new CallFuctionElement(ref, "func", 1);
		CallFuctionElement lae7 = new CallFuctionElement(ref, "func", argus);
		CallFuctionElement lae8 = new CallFuctionElement(ref, "func", argus, 1);
		System.out.println(lae.toString() + lae2.toString() + lae3.toString() +lae4.toString()
				+lae5.toString() + lae6.toString() + lae7.toString() +lae8.toString());
	}
}
